
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<%@ page contentType="text/html; charset=utf-8"%>
	<%@ include file="/commons/taglibs.jsp"%>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>增加下拉选项</title>
		<%@ include file="/commons/css_js_head.jsp"%>
<script type="text/javascript">

//复写Url
//doSaveUrl = "${ctx }/base/tsOptionsAction!doSave.ts?code=${code}";
doReturnUrl = "${ctx }/base/userapplytypeAction!doList.ts?code=${code}";
doSaveUrl = "${ctx }/base/userapplytypeAction!doSave.ts";
//校验用户账号是否存在
function checkOptionsNameIsExist() {
	var txtObj = document.getElementById("userapplytype.name");
	var userAccountInfo = document.getElementById("userapplytypeName");
	var tName = (txtObj.value).replace(/[ ]/g,"");
	if(tName == ""){
		var innerHtml = "<span class='ts_red'>请输入名称！<\/span>";
		getFocus(txtObj,userAccountInfo,innerHtml);
		return false;
	}else if(tName.length < 2 || tName.length > 32){
		var innerHtml = "<span class='ts_red'>名称只能在2-32个字符之间！<\/span>";
		cleanDataAndGetFocus(txtObj,userAccountInfo,innerHtml);
		return false;
	}
	
    $.ajax({
      type : "post",
      url : "${ctx }/base/userapplytypeAction!doCheckOptionsNameIsExist.ts",
      cache: false,
      data : "&name="+tName,
      success : function(data){
      
      if( data == "true" )
       {
           var innerHtml = "<span class='ts_red'>该名称已经存在，请重新输入！<\/span>";
           userAccountInfo.innerHTML=innerHtml;
           txtObj.value = "";
           txtObj.focus();
           return false;
        }
       else
       {
           var innerHtml = "<span class='ts_green'>验证通过，该名称可以使用！<\/span>";
           userAccountInfo.innerHTML=innerHtml;
           return true;
       }
      },
     error: function(){
     	   var innerHtml = "<span class='ts_red'>服务繁忙，请稍后再试！<\/span>";
           userAccountInfo.innerHTML=innerHtml;
           txtObj.value = "";
           return false;
     	}
   });
  	return true;
}



//验证用户名称
function checkUserName() {

	var name = document.getElementById("userapplytype.name");
	var optionsName = document.getElementById("userapplytypeName");
	
	if((name.value).replace(/[ ]/g,"") == ""){
		var innerHtml = "<span class='ts_red'>请输入用户名称！<\/span>";
		cleanData(name,userapplytypeName,innerHtml);
		return false;
	}else{
		var innerHtml = "<span class='ts_green'>验证通过！<\/span>";
		disInfo(userapplytypeName,innerHtml);
		return true;
	}
}


function checkForm(){
	
	if(
		
		checkUserName() 
		){
		return true;
	}else{
		return false;
	}
}

//保存
function doSave() {

	var _form = document.forms[0];
	if (doSaveUrl == '') {
		alert('请设置正确的URL!');
		return false;
	}
	if(checkForm()){
		_form.action = doSaveUrl;
		_form.submit();
	}
}
</script>
	</head>

	<body style="overflow-x: hidden">
		<div class="mTitle">
			<span class="hidsearch"></span>
			<b class="bbig">增加应用平台类型</b> 带
			<b class="fred"> * </b>号为必填项
		</div>

		<form action="/base/userapplytypeAction" method="post">
			<!--list -->
			<div class="mainAdd">
				<table class="addTable">

					
					<tr>
						<th>
							<b class="fred"> * </b> 应用平台名称：
							
						</th>
						<td >
							<s:textfield name="userapplytype.name"  onblur="checkOptionsNameIsExist();" maxlength="32" theme="simple" />
							<span id="userapplytypeName"></span>
						</td>
						
					</tr>

					<tr>
						<th>
							<b class="fred"> * </b> 类型：
						</th>
						<td>
						     <s:select
                                 theme="simple"
                                 name="userapplytype.optionId"
                                 list="#request.list" 
                                 cssStyle="width:83px;"	
                                 listKey="theId" 
                                 listValue="name"
                			     id="select">
							</s:select>
						</td>
						
					</tr>

					

				</table>
			</div>
			<!--end list -->
			<div class="addToolbar">
				<p>
					<input class="btn" name="btn_confirm" value="确定" type="button"
						onclick="doSave();" />
					<input class="btn" name="btn_return" value="返回" type="button"
						onclick="doReturn();" ; />
				</p>
			</div>

		</form>

	</body>

<script type="text/javascript">
//document.getElementById("options.name").focus();

document.onkeydown = function(e) {
	if (!e)
		e = window.event;//火狐中是 window.event
	if ((e.keyCode || e.which) == 13) {
		doSave();
	}
}
</script>
</html>
